//	获取url传值
function getQueryString(name) {
	var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
	if (result == null || result.length < 1) {return "";}
		return result[1];
}
id = getQueryString("id");
$.validator.setDefaults({
    submitHandler: function() {
      	var params = $(".form-div").serialize(); 
      	$.ajax( {  
                type : "POST",  
                url : serverIP+"/user/goodsInfo/save?goodsId="+id,  
                data : params,  
                xhrFields: {
	                withCredentials: true    // 设置sessionId相同
	            },
                success : function(data) {
                	if(data.code==0){
                		alert("新增供应商管理成功");
                	}else{
                		alert(data.msg);
                	}
                }  
        }); 
    }
});

$(document).ready(function() {
	$('.form-div').validate({
		rules: {
		 	goodsCode: "required",
		 	supplier: "required"
		},
		messages: {
	      	goodsCode: "请输入编码",
	      	supplier: "请输入供应商"
		}	
	})
})
$(function(){
	if($(".admin").height()<700){
		$('.nav-btn').height('50px').find('img').hide();
	}else{
		$('.nav-btn').height('150px').find('img').show();
	}
})
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
	if($(".admin").height()<600){
		$('.nav-btn').height('50px').find('img').hide();
	}else{
		$('.nav-btn').height('150px').find('img').show();
	}
}
$(".icon-ok").click(function() {
	$(".submit").click();
})
$(".back").click(function() {
	history.back();
});